home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / jce.jar / javax / crypto / KeyAgreement.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-07-27  |  5.6 KB  |  249 lines

  1. package javax.crypto;
  2.  
  3. import java.security.InvalidAlgorithmParameterException;
  4. import java.security.InvalidKeyException;
  5. import java.security.Key;
  6. import java.security.NoSuchAlgorithmException;
  7. import java.security.NoSuchProviderException;
  8. import java.security.Provider;
  9. import java.security.ProviderException;
  10. import java.security.SecureRandom;
  11. import java.security.spec.AlgorithmParameterSpec;
  12. import java.util.Iterator;
  13. import java.util.List;
  14. import sun.security.jca.GetInstance;
  15. import sun.security.util.Debug;
  16.  
  17. public class KeyAgreement {
  18.    // $FF: renamed from: a sun.security.util.Debug
  19.    private static final Debug field_0 = Debug.getInstance("jca", "KeyAgreement");
  20.    // $FF: renamed from: b java.security.Provider
  21.    private Provider field_1;
  22.    // $FF: renamed from: c javax.crypto.KeyAgreementSpi
  23.    private KeyAgreementSpi field_2;
  24.    // $FF: renamed from: d java.lang.String
  25.    private final String field_3;
  26.    // $FF: renamed from: e java.security.Provider.Service
  27.    private Provider.Service field_4;
  28.    // $FF: renamed from: f java.util.Iterator
  29.    private Iterator field_5;
  30.    // $FF: renamed from: g java.lang.Object
  31.    private final Object field_6;
  32.    // $FF: renamed from: h int
  33.    private static int field_7 = 10;
  34.    // $FF: renamed from: i int
  35.    private static final int field_8 = 1;
  36.    // $FF: renamed from: j int
  37.    private static final int field_9 = 2;
  38.  
  39.    protected KeyAgreement(KeyAgreementSpi var1, Provider var2, String var3) {
  40.       this.field_2 = var1;
  41.       this.field_1 = var2;
  42.       this.field_3 = var3;
  43.       this.field_6 = null;
  44.    }
  45.  
  46.    private KeyAgreement(Provider.Service var1, Iterator var2, String var3) {
  47.       this.field_4 = var1;
  48.       this.field_5 = var2;
  49.       this.field_3 = var3;
  50.       this.field_6 = new Object();
  51.    }
  52.  
  53.    public final String getAlgorithm() {
  54.       return this.field_3;
  55.    }
  56.  
  57.    public static final KeyAgreement getInstance(String var0) throws NoSuchAlgorithmException {
  58.       List var1 = GetInstance.getServices("KeyAgreement", var0);
  59.       Iterator var2 = var1.iterator();
  60.  
  61.       while(var2.hasNext()) {
  62.          Provider.Service var3 = (Provider.Service)var2.next();
  63.          if (SunJCE_b.b(var3.getProvider())) {
  64.             return new KeyAgreement(var3, var2, var0);
  65.          }
  66.       }
  67.  
  68.       throw new NoSuchAlgorithmException("Algorithm " + var0 + " not available");
  69.    }
  70.  
  71.    public static final KeyAgreement getInstance(String var0, String var1) throws NoSuchAlgorithmException, NoSuchProviderException {
  72.       GetInstance.Instance var2 = SunJCE_b.a("KeyAgreement", KeyAgreementSpi.class, var0, var1);
  73.       return new KeyAgreement((KeyAgreementSpi)var2.impl, var2.provider, var0);
  74.    }
  75.  
  76.    public static final KeyAgreement getInstance(String var0, Provider var1) throws NoSuchAlgorithmException {
  77.       GetInstance.Instance var2 = SunJCE_b.a("KeyAgreement", KeyAgreementSpi.class, var0, var1);
  78.       return new KeyAgreement((KeyAgreementSpi)var2.impl, var2.provider, var0);
  79.    }
  80.  
  81.    // $FF: renamed from: a () void
  82.    void method_0() {
  83.       if (this.field_2 == null) {
  84.          synchronized(this.field_6) {
  85.             if (this.field_2 == null) {
  86.                if (field_0 != null) {
  87.                   int var2 = --field_7;
  88.                   if (var2 >= 0) {
  89.                      field_0.println("KeyAgreement.init() not first method called, disabling delayed provider selection");
  90.                      if (var2 == 0) {
  91.                         field_0.println("Further warnings of this type will be suppressed");
  92.                      }
  93.  
  94.                      (new Exception("Call trace")).printStackTrace();
  95.                   }
  96.                }
  97.  
  98.                Exception var8 = null;
  99.  
  100.                while(this.field_4 != null || this.field_5.hasNext()) {
  101.                   Provider.Service var3;
  102.                   if (this.field_4 != null) {
  103.                      var3 = this.field_4;
  104.                      this.field_4 = null;
  105.                   } else {
  106.                      var3 = (Provider.Service)this.field_5.next();
  107.                   }
  108.  
  109.                   if (SunJCE_b.b(var3.getProvider())) {
  110.                      try {
  111.                         Object var4 = var3.newInstance((Object)null);
  112.                         if (var4 instanceof KeyAgreementSpi) {
  113.                            this.field_2 = (KeyAgreementSpi)var4;
  114.                            this.field_1 = var3.getProvider();
  115.                            this.field_4 = null;
  116.                            this.field_5 = null;
  117.                            return;
  118.                         }
  119.                      } catch (Exception var6) {
  120.                         var8 = var6;
  121.                      }
  122.                   }
  123.                }
  124.  
  125.                ProviderException var9 = new ProviderException("Could not construct KeyAgreementSpi instance");
  126.                if (var8 != null) {
  127.                   var9.initCause(var8);
  128.                }
  129.  
  130.                throw var9;
  131.             }
  132.          }
  133.       }
  134.    }
  135.  
  136.    // $FF: renamed from: a (javax.crypto.KeyAgreementSpi, int, java.security.Key, java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom) void
  137.    private void method_1(KeyAgreementSpi var1, int var2, Key var3, AlgorithmParameterSpec var4, SecureRandom var5) throws InvalidKeyException, InvalidAlgorithmParameterException {
  138.       if (var2 == 1) {
  139.          var1.engineInit(var3, var5);
  140.       } else {
  141.          var1.engineInit(var3, var4, var5);
  142.       }
  143.  
  144.    }
  145.  
  146.    // $FF: renamed from: a (int, java.security.Key, java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom) void
  147.    private void method_2(int var1, Key var2, AlgorithmParameterSpec var3, SecureRandom var4) throws InvalidKeyException, InvalidAlgorithmParameterException {
  148.       synchronized(this.field_6) {
  149.          if (this.field_2 != null) {
  150.             this.method_1(this.field_2, var1, var2, var3, var4);
  151.          } else {
  152.             Exception var6 = null;
  153.  
  154.             while(this.field_4 != null || this.field_5.hasNext()) {
  155.                Provider.Service var7;
  156.                if (this.field_4 != null) {
  157.                   var7 = this.field_4;
  158.                   this.field_4 = null;
  159.                } else {
  160.                   var7 = (Provider.Service)this.field_5.next();
  161.                }
  162.  
  163.                if (var7.supportsParameter(var2) && SunJCE_b.b(var7.getProvider())) {
  164.                   try {
  165.                      KeyAgreementSpi var8 = (KeyAgreementSpi)var7.newInstance((Object)null);
  166.                      this.method_1(var8, var1, var2, var3, var4);
  167.                      this.field_1 = var7.getProvider();
  168.                      this.field_2 = var8;
  169.                      this.field_4 = null;
  170.                      this.field_5 = null;
  171.                      return;
  172.                   } catch (Exception var10) {
  173.                      if (var6 == null) {
  174.                         var6 = var10;
  175.                      }
  176.                   }
  177.                }
  178.             }
  179.  
  180.             if (var6 instanceof InvalidKeyException) {
  181.                throw (InvalidKeyException)var6;
  182.             } else if (var6 instanceof InvalidAlgorithmParameterException) {
  183.                throw (InvalidAlgorithmParameterException)var6;
  184.             } else if (var6 instanceof RuntimeException) {
  185.                throw (RuntimeException)var6;
  186.             } else {
  187.                String var12 = var2 != null ? var2.getClass().getName() : "(null)";
  188.                throw new InvalidKeyException("No installed provider supports this key: " + var12, var6);
  189.             }
  190.          }
  191.       }
  192.    }
  193.  
  194.    public final Provider getProvider() {
  195.       this.method_0();
  196.       return this.field_1;
  197.    }
  198.  
  199.    public final void init(Key var1) throws InvalidKeyException {
  200.       this.init(var1, SunJCE_b.b);
  201.    }
  202.  
  203.    public final void init(Key var1, SecureRandom var2) throws InvalidKeyException {
  204.       if (this.field_2 != null) {
  205.          this.field_2.engineInit(var1, var2);
  206.       } else {
  207.          try {
  208.             this.method_2(1, var1, (AlgorithmParameterSpec)null, var2);
  209.          } catch (InvalidAlgorithmParameterException var4) {
  210.             throw new InvalidKeyException(var4);
  211.          }
  212.       }
  213.  
  214.    }
  215.  
  216.    public final void init(Key var1, AlgorithmParameterSpec var2) throws InvalidKeyException, InvalidAlgorithmParameterException {
  217.       this.init(var1, var2, SunJCE_b.b);
  218.    }
  219.  
  220.    public final void init(Key var1, AlgorithmParameterSpec var2, SecureRandom var3) throws InvalidKeyException, InvalidAlgorithmParameterException {
  221.       if (this.field_2 != null) {
  222.          this.field_2.engineInit(var1, var2, var3);
  223.       } else {
  224.          this.method_2(2, var1, var2, var3);
  225.       }
  226.  
  227.    }
  228.  
  229.    public final Key doPhase(Key var1, boolean var2) throws InvalidKeyException, IllegalStateException {
  230.       this.method_0();
  231.       return this.field_2.engineDoPhase(var1, var2);
  232.    }
  233.  
  234.    public final byte[] generateSecret() throws IllegalStateException {
  235.       this.method_0();
  236.       return this.field_2.engineGenerateSecret();
  237.    }
  238.  
  239.    public final int generateSecret(byte[] var1, int var2) throws IllegalStateException, ShortBufferException {
  240.       this.method_0();
  241.       return this.field_2.engineGenerateSecret(var1, var2);
  242.    }
  243.  
  244.    public final SecretKey generateSecret(String var1) throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException {
  245.       this.method_0();
  246.       return this.field_2.engineGenerateSecret(var1);
  247.    }
  248. }
  249.